/************************************************
*@brief:		This class manipulates Strings
*@author:		K. TANGAO <futurchercheur1@gmail.com>
*@file:			formatingClass.h
*@date:			27/11/2008
*@Version:		1.0
*************************************************/


#ifndef _FORMATING
#define _FORMATING


#include <string>
#include "glfont2.h"

//class glfont::GLFont;


class formatString
{
	public:
		// constructors
		formatString(std::string myString);
		~formatString();

		
		/*
		* @comment:The number of character inside the string we are using
		* @param[in] void
		* @return the number of Characters
		*/
		long getNbChar();

		
		/*
		* @comment: The number of character inside the string we are using
		* @param[in] void
		* @return the number of the words
		*/
		long getNbWords();

		/*
		* @comment:Get the Font using
		* @param[in] void
		* @return a pointer on the Font
		*/
		glfont::GLFont* getFontUse();

		
		/*
		* @comment: set the Font to be used. In another word load the font
		* @param[in] the location of the .glf file
		* @return bool: True if success and false if not
		*/
		bool loadFont(std::string fontLocation, unsigned int tex);

		
		/*
		* @comment:get the size of each word in Pixel
		* @param[in] The word you want manipulate
		* @return The width in Pixel
		*/
		int getWordWidthP(std::string word);
		
		
		/*
		* @comment:get the interLine in Pixels
		* @param[in] nothing
		* @return interline value
		*/
		int getInterLine();


		/*
		* @comment:get the wordTable
		* @param[in] nothing
		* @return the table
		*/
		std::string * getWordTable();



		/*
		* @comment:Set the string to manipulate
		* @param[in] the new string
		* @return void
		*/
		void setString(std::string newString);

		
		/*
		* @comment:Set interlines
		* @param[in] the value of Interline. The default value -1 equals to %40 of the height of a line
		* @return void
		*/
		void setInterLine(int interLineValue = -1);
		
		/*
		* @comment:get the height of a line in Pixels
		* @param[in] void
		* @return the value
		*/
		int getLineHeightP();


		/*
		* @comment: draw a word
		* @param[in] 
		*			- wordXPos, the XPos of the Word
		*			- wordYPos, the YPos of the Word
		*			- word, the word being drawn
		* @return void
		*/
		void drawWord(float wordXPos, float wordYPos, std::string word);


		/*
		* @comment:draw a line of text
		* @param[in] 
		*			- widthP, the width of the line in Pixel
		*			- xStart, the xPosition of the first character (OpenGL Coordonates)
		*			- yStart, the yPosition of the first character (OpenGL Coordonates)
		*			- startPos, The position of the word to begin drawing in the wordTable
		* @param[out] the position of the next word in the wordTable
		* @return void
		*/
		void drawLine(int widthP, float xStart, float yStart, int * nextWordToDraw, int startPos);



		/*
		* @comment:draw the whole String
		* @param[in] 
		*			- widthP, the width of the rectangle
		*			- HeightP, the height of the rectangle
		*			- PosX, the xPosition of the top left corner of the rectangle(OpenGL Coordonates)
		*			- PosY, the yPosition of the top left Corner of the rectangle(OpenGL Coordonates)
		* @return void
		*/
		void drawTheWholeText(int widthP, int HeightP, float PosX, float PosY);

		/*
		* @comment:initialize the Object
		* @param[in] the font location
		* @return void
		*/
		void initialize(std::string fontLocation, unsigned int tex);

		


	protected:
		// the text we are manipulating
		std::string theString;
		// the number of Character
		long nbChar;
		// the number of words without punctuations
		long nbWords;
		// The interline value
		int interLine;
		// the GLFont used to draw the text
		glfont::GLFont* myFont;
		// a table of all the words
		std::string *wordTable;

		//Private function to change the number of Character
		void setNbChar();
		//Private function to change the nbWords value
		void setNbWords();
		//Private function to set the words table
		void setWordTable();



};

#endif

